package Mypackage.Runner;

import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SettingsEditor;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

/**
 * Uses code from the intellij-batch plugin.
 *
 * @author wibotwi, jansorg
 */
public class PerlRunConfigurationEditor extends SettingsEditor<PerlRunConfiguration> {
    private PerlRunConfigurationForm myForm;

    public PerlRunConfigurationEditor(PerlRunConfiguration batchRunConfiguration) {
        this.myForm = new PerlRunConfigurationForm(batchRunConfiguration);
    }

    @Override
    protected void resetEditorFrom(PerlRunConfiguration runConfiguration) {
        PerlRunConfiguration.copyParams(runConfiguration, myForm);
    }

    @Override
    protected void applyEditorTo(PerlRunConfiguration runConfiguration) throws ConfigurationException {
        PerlRunConfiguration.copyParams(myForm, runConfiguration);
    }

    @Override
    @NotNull
    protected JComponent createEditor() {
        return myForm.getRootPanel();
    }

    @Override
    protected void disposeEditor() {
        myForm = null;
    }
}